package exam.common.util;

import java.util.List;

public class StringCommonUtil {
	
	private static StringBuffer strBuffer = null;
	
	public static boolean isEmpty(String str) {
		boolean rs = false;
		try {
			rs = str.isEmpty();
		} catch(NullPointerException e) {
			rs = true;
		}
		return rs;
	}
	
	public static boolean isNotEmpty(String str) {
		return !isEmpty(str);
	}
	
	@SuppressWarnings("unchecked")
	public static String replaceStartAndEndForList(List<?> list, String charStart, String charEnd) {
		strBuffer = new StringBuffer(converListToString((List<Object>) list));
		if(isNotEmpty(strBuffer.toString())) {
			strBuffer.replace(0, 1, charStart).replace(strBuffer.length() - 1, strBuffer.length(), charEnd);
		}
		return strBuffer.toString();
	}
	
	public static String converListToString(List<Object> list) {
		if (NullCheckUtil.isNUll(list)) {
			return "";
		} else {
			return list.toString();
		}
	}
}
